Q: What is necessary when we need to create a new field in craft?
Solution: Whenever someone creates a new field in Craft, they must specify what type of field it is. They are organized into Field Groups for convenience, but Field Groups have very little relevance anywhere else in the system.
Q: What does the getInputHtml() return?
Solution: The method getInputHtml() returns a fieldtype’s input HTML. It accepts two arguments: $name and $value.
Q: How many arguments does the getInputHtml() accept?
Solution: The method getInputHtml() returns a fieldtype’s input HTML. The method getInputHtml(0 accepts two arguments: $name and $value. $name is the name you should assign your HTML input name= attribute, and $value is the field’s current value (either from the DB, or the POST data if there was a validation error).
Q: Which is the method used to process on the input post data before it is saved to the database?
Solution: defineSettings() method returns an array whose keys define the setting names, and values define the parameters (the type of value, etc). If you need to do any processing on your settings’ post data before they’re saved to the database’s content table, you can do it with the prepSettings() method.
Q: What is the purpose of the parameter $name ?
Solution: getinputhtml() accepts two arguments: $name and $value. The parameter $name is the name you should assign your HTML input name= attribute.
Q: What does the method defineSettings() return?
Solution: The defineSettings() method returns an array whose keys define the setting names, and values define the parameters (the type of value, etc). If you need to do any processing on your settings’ post data before they’re saved to the database’s content table, you can do it with the prepSettings() method.
Q: What is the purpose of the parameter $value?
Solution: getinputhtml() accepts two arguments: $name and $value. The parameter $value is the field’s current value (either from the DB, or the POST data if there was a validation error).
Q: When does the defineContentAttribute() method return a false?
Solution: If your fieldtype is storing data in its own table, and doesn’t have any use for a column within the main content table, you may also set defineContentAttribute() to return false. By default, BaseFieldType sets the column to VARCHAR(255), but you can override that with defineContentAttribute().
Q: How many events does the BaseFieldType provide?
Solution: BaseFieldType provides three events that you can latch code onto: onBeforeSave() : Called right before a field is saved. onAfterSave() : Called right after a field is saved, and $this->model->id is set. onAfterElementSave() : Called right after an element is saved, and $this->element->id is set.
Q: Which method is called right before a field is saved?
Solution: BaseFieldType provides three events that you can latch code onto:onBeforeSave(), onAfterSave() and onAfterElementSave(). The method onBeforeSave() is called right before a field is saved.
You Have Score    | /10 |